# coding:utf-8

import os
import re
import traceback
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler


class MyHttpHandler(BaseHTTPRequestHandler):
    '''
    处理http请求
    '''

    def do_GET(self):
        '''
        处理get请求
        :return:
        '''
        print self.command
        print self.path
        print self.request_version
        print self.headers

        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        self.wfile.write(self.path)


def start():
    # 设置服务
    http_server = HTTPServer(('127.0.0.1', 8100), MyHttpHandler)
    # 一直监听
    http_server.serve_forever()


if __name__ == '__main__':
    start()
